// 解耦
// 这个文件专门封装和用户相关的接口
import request from '@/utils/request'
// import store from '@/store'
export function login (data) {
  return request({
    method: 'post',
    url: '/app/v1_0/authorizations',
    data: data
  })
}

// 发送手机短信
export function sendSms (mobile) {
  return request({
    method: 'GET',
    url: `/app/v1_0/sms/codes/${mobile}`
  })
}

export function getUser () {
  return request({
    method: 'GET',
    url: '/app/v1_0/user'
    // headers: {
    //   Authorization: `Bearer ${store.state.user.token}`
    // }
  })
}

// 获取频道列表数据
export function getChannelList () {
  return request({
    method: 'GET',
    url: '/app/v1_0/user/channels'
  })
}

// 关注用户
export function addFollow (target) {
  return request({
    method: 'POST',
    url: '/app/v1_0/user/followings',
    data: {
      target
    }
  })
}

// 取消关注用户
export function deleteFollow (target) {
  return request({
    method: 'DELETE',
    url: `/app/v1_0/user/followings/${target}`
  })
}

// 获取用户个人资料
export function getUserProfile () {
  return request({
    method: 'GET',
    url: '/app/v1_0/user/profile'
  })
}

// 编辑个人资料
export function updateUserProfile (data) {
  return request({
    method: 'PATCH',
    url: '/app/v1_0/user/profile',
    data
  })
}

// 更新头像
export function updateUserPhoto (data) {
  return request({
    method: 'PATCH',
    url: '/app/v1_0/user/photo',
    data
  })
}
